var __extends =
    (this && this.__extends) ||
    (function () {
      var e = function (t, o) {
        return (e =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (e, t) {
              e.__proto__ = t;
            }) ||
          function (e, t) {
            for (var o in t)
              Object.prototype.hasOwnProperty.call(t, o) && (e[o] = t[o]);
          })(t, o);
      };
      return function (t, o) {
        function n() {
          this.constructor = t;
        }
        if ("function" != typeof o && null !== o)
          throw new TypeError(
            "Class extends value " + String(o) + " is not a constructor or null"
          );
        e(t, o),
          (t.prototype =
            null === o
              ? Object.create(o)
              : ((n.prototype = o.prototype), new n()));
      };
    })(),
  PuranceView = (function (e) {
    function t() {
      var t = e.call(this) || this;
      return (
        (t.onLoadTotalPurchValue = {
          caller: t,
          code: 15802,
          method: function (e) {
            0 == e.code &&
              ((t.label_purchase_value.text = e.data.v1),
              (t.label_chongzhi_money.text = e.data.v2 + " 金"));
          },
        }),
        (t.qianzhuangLoadFn = {
          caller: t,
          code: 1451,
          method: function (e) {
            if (8 == e.code)
              return ToastView.toastView(e.msg), void t.onPreBack();
            t.label_purchase_value.text = e.data.gold;
          },
        }),
        t.btn_puracseBack.on(Laya.Event.CLICK, t, t.onPreBack),
        t.btn_pay.on(Laya.Event.CLICK, t, t.onPayOrderDidClick),
        (t.text_money_value.restrict = "0-9"),
        t.text_money_value.on(Laya.Event.FOCUS, t, t.onTextFocusFn),
        t.btn_money_one.on(Laya.Event.CLICK, t, t.onPayMoneySelectedAction),
        t.btn_money_two.on(Laya.Event.CLICK, t, t.onPayMoneySelectedAction),
        t.btn_money_three.on(Laya.Event.CLICK, t, t.onPayMoneySelectedAction),
        t.btn_money_four.on(Laya.Event.CLICK, t, t.onPayMoneySelectedAction),
        t.btn_money_five.on(Laya.Event.CLICK, t, t.onPayMoneySelectedAction),
        t.btn_money_six.on(Laya.Event.CLICK, t, t.onPayMoneySelectedAction),
        t.btn_chongzhihaoli.on(
          Laya.Event.CLICK,
          t,
          t.onDidClickChongZhiHaoLiFn
        ),
        WebSocketService.addListener(t.qianzhuangLoadFn),
        WebSocketService.addListener(t.onLoadTotalPurchValue),
        t
      );
    }
    return (
      __extends(t, e),
      (t.openView = function (e) {
        return (
          null == this.puracnceVC && (this.puracnceVC = new t()),
          this.puracnceVC.initShowView(),
          (this.puracnceVC.money_type = e),
          "money_card_38" == e
            ? ((this.puracnceVC.text_money_value.text = "38"),
              (this.puracnceVC.text_money_value.disabled = !0),
              (this.puracnceVC.money_price = "38"))
            : "money_card_98" == e
            ? ((this.puracnceVC.text_money_value.text = "98"),
              (this.puracnceVC.text_money_value.disabled = !0),
              (this.puracnceVC.money_price = "98"))
            : ((this.puracnceVC.text_money_value.text = ""),
              (this.puracnceVC.text_money_value.disabled = !1)),
          WebSocketService.send({ c: 1451, d: { pageNum: 0 } }),
          WebSocketService.send({ c: 15802, d: null }),
          this.puracnceVC
        );
      }),
      (t.prototype.initShowView = function () {
        (this.lbl_money_one.visible = !1),
          (this.lbl_money_two.visible = !1),
          (this.lbl_money_three.visible = !1),
          (this.lbl_money_four.visible = !1),
          (this.lbl_money_five.visible = !1),
          (this.lbl_money_six.visible = !1);
      }),
      (t.prototype.onTextFocusFn = function () {
        this.initShowView();
      }),
      (t.prototype.onDidClickChongZhiHaoLiFn = function () {
        RechargeMoneyGiftDialog.showRechargeDiaog("");
      }),
      (t.prototype.onPayMoneySelectedAction = function (e) {
        (this.lbl_money_one.visible = !1),
          (this.lbl_money_two.visible = !1),
          (this.lbl_money_three.visible = !1),
          (this.lbl_money_four.visible = !1),
          (this.lbl_money_five.visible = !1),
          (this.lbl_money_six.visible = !1),
          "item0" == e.target.name
            ? ((this.money_price = "10"),
              (this.money_body = "10元购买1500金砖"),
              (this.lbl_money_one.visible = !0))
            : "item1" == e.target.name
            ? ((this.money_price = "30"),
              (this.money_body = "30元购买4500金砖"),
              (this.lbl_money_two.visible = !0))
            : "item2" == e.target.name
            ? ((this.money_price = "50"),
              (this.money_body = "50元购买7500金砖"),
              (this.lbl_money_three.visible = !0))
            : "item3" == e.target.name
            ? ((this.money_price = "100"),
              (this.money_body = "100元购买15000金砖"),
              (this.lbl_money_four.visible = !0))
            : "item4" == e.target.name
            ? ((this.money_price = "300"),
              (this.money_body = "300元购买45000金砖"),
              (this.lbl_money_five.visible = !0))
            : "item5" == e.target.name &&
              ((this.money_price = "500"),
              (this.money_body = "500元购买75000金砖"),
              (this.lbl_money_six.visible = !0)),
          (this.text_money_value.text = this.money_price);
      }),
      (t.prototype.onPreBack = function () {
        this.removeSelf();
      }),
      (t.prototype.onPayOrderDidClick = function () {
        var e = "充值" + this.text_money_value.text + "元";
        this.text_money_value.text.length > 0
          ? ((this.money_price = this.text_money_value.text),
            (this.money_body = e),
            this.addOrder())
          : ToastView.toastView("请输入充值金额!!!");
      }),
      (t.prototype.addOrder = function () {
        var e = laya.net.LocalStorage.getItem("openid");
        Browser.onWeiXin && e ? this.addWweiXinOrder() : this.addAlipayOrder();
      }),
      (t.prototype.addWeixinOrder = function () {
        var e = new Ajax(this),
          t = "1";
        ("money_card_38" != this.money_type &&
          "money_card_98" != this.money_type) ||
          (t = "3");
        var o = {
          body: Environment.appName + "-" + this.money_body,
          purpose: t,
          totalFee: this.money_price,
          tradeType: "MWEB",
          userCode: Global.roleId,
          userId: laya.net.LocalStorage.getItem("userId"),
        };
        (e.success = this.payWapComplete),
          e.post(Environment.subarea + "/user-service/recharage/weixin", o);
      }),
      (t.prototype.payWapComplete = function (e) {
        0 == e.code
          ? Browser.window.location.assign(e.data)
          : ToastView.toastView(e.msg);
      }),
      (t.prototype.addAlipayOrder = function () {
        var e = new Ajax(this),
          t = "1";
        ("money_card_38" != this.money_type &&
          "money_card_98" != this.money_type) ||
          (t = "3");
        var o = {
          body: Environment.appName + "-" + this.money_body,
          purpose: t,
          totalFee: this.money_price,
          tradeType: "MWEB",
          userCode: Global.roleId,
          userId: laya.net.LocalStorage.getItem("userId"),
        };
        (e.success = this.payAlipayComplete),
          e.post(Environment.subarea + "/user-service/recharage/alipay", o);
      }),
      (t.prototype.payAlipayComplete = function (e) {
        0 == e.code
          ? (console.log(e.data),
            (Browser.document.getElementById("payform").innerHTML = e.data),
            Browser.document.forms[0].submit())
          : ToastView.toastView(e.msg);
      }),
      (t.prototype.addWweiXinOrder = function () {
        if (Browser.onWeiXin) {
          var e = laya.net.LocalStorage.getItem("openid");
          if (null != e && "" != e) {
            var t = new Ajax(this);
            t.success = this.addOrderComplete;
            var o = {
              body: Environment.appName + "-" + this.money_body,
              openid: e,
              purpose: 1,
              totalFee: this.money_price,
              tradeType: "JSAPI",
              userCode: Global.roleId,
              userId: laya.net.LocalStorage.getItem("userId"),
            };
            t.post(Environment.subarea + "/user-service/recharage/weixin", o);
          } else ToastView.toastView("获取不到openid");
        } else ToastView.toastView("请在微信公号菜单中打开游戏");
      }),
      (t.prototype.addOrderComplete = function (e) {
        0 == e.code
          ? ((this.data = JSON.parse(e.data)),
            void 0 === Browser.window.WeixinJSBridge
              ? Browser.document.addEventListener
                ? Browser.document.addEventListener(
                    "WeixinJSBridgeReady",
                    this.onBridgeReady,
                    !1
                  )
                : Browser.document.attachEvent &&
                  (Browser.document.attachEvent(
                    "WeixinJSBridgeReady",
                    this.onBridgeReady
                  ),
                  Browser.document.attachEvent(
                    "onWeixinJSBridgeReady",
                    this.onBridgeReady
                  ))
              : this.onBridgeReady())
          : ToastView.toastView(e.msg);
      }),
      (t.prototype.onBridgeReady = function () {
        Browser.window.WeixinJSBridge.invoke(
          "getBrandWCPayRequest",
          this.data,
          this.payComplete
        );
      }),
      (t.prototype.payComplete = function (e) {
        "get_brand_wcpay_request:ok" == e.err_msg
          ? (ToastView.toastView("充值成功"),
            WebSocketService.send({ c: 1451, d: { pageNum: 0 } }),
            WebSocketService.send({ c: 15802, d: null }))
          : Alert.openText(e.err_msg);
      }),
      t
    );
  })(ui.MoneyBankController.PurchaseViewUI);
